using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using FiltronASP.Models;
using FiltronASP.Models.DAO;
using FiltronASP.Models.DAO.Extensions;
using FiltronASP.Models.DAO.Interfaces;

namespace FiltronASP.Helpers.Routes
{
    /// <summary>
    /// Klasa pomocnicza do generowania linkow na podstawie mapowan zawartych w klasie zarejestrowanych routow.
    /// </summary>
    public static class LanguagesRoutesHelper
    {
        /// <summary>
        /// Klasa pomocnicza do generowania linkow zwiazanych z routem <code>LanguagesList</code>.
        /// </summary>
        /// <param name="urlHelper">url helper z c#</param>
        /// <param name="page">strona w paginacji</param>
        /// <param name="language">aktualna wersja jezykowa</param>
        /// <returns></returns>
        public static string GenerateLanguagesListRoute(this UrlHelper urlHelper, int? page, Language language)
        {
            if ((!page.HasValue) || (page <= 0))
            {
                page = 1;
            }   //if
            if (language != null)
            {
                return urlHelper.RouteUrl("LanguagesList", new { page = (page), currentLanguageId = (language.language_id) });
            } else  {   //if
                return urlHelper.RouteUrl("LanguagesListNoLanguage", new { page = (page) });
            }   //else
        }

        /// <summary>
        /// Klasa pomocnicza do generowania linkow zwiazanych z routem <code>LanguagesList</code>.
        /// </summary>
        /// <param name="urlHelper">url helper z c#</param>
        /// <param name="language">aktualna wersja jezykowa</param>
        /// <returns></returns>
        public static string GenerateLanguagesListRoute(this UrlHelper urlHelper, Language language)
        {
            int? page = 1;
            if (language != null)
            {
                return urlHelper.RouteUrl("LanguagesList", new { page = (page), currentLanguageId = (language.language_id) });
            }
            else
            {   //if
                return urlHelper.RouteUrl("LanguagesListNoLanguage", new { page = (page) });
            }   //else
        }

    }
}
